package cn.hyy.hrm.doc;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * es中数据的存储的格式
 * <p>
 * (1)要作为查询的字段 - index
 * 课程类型的ID
 * 关键字搜索：课程名称、课程类型的名称、机构名称
 * 收费规则(charge):1,2 Integer
 * 课程等级(grade): 1,2,3 Long
 * (2)前端要显示的字段 - store
 * 课程名称
 * 收费规则
 * 图片信息 resources
 * 价格 price
 * 描述 description
 * 介绍 intro
 * 收费规则
 * qq
 * <p>
 * <p>
 * (3)排序的字段 - index
 * 上线时间
 * 价格
 * <p>
 * 都要保存到Document中
 */
@Document(indexName = "hrm", type = "Course")
@Data
public class CourseDoucment {

    @Id
    private Long id;

    @Field(type= FieldType.Long)
    private Long typeId;
    @Field(type = FieldType.Text)
    private String all;//"课程名称 课程类型的名称 机构名称" 索引的时候会分词

    @Field(type = FieldType.Long,store = true)
    private Long charge;//收费规则
    @Field(type = FieldType.Long,store = true)
    private Long grade;//等级

    @Field(type = FieldType.Keyword,index = false,store = true)
    private String name;
    @Field(type = FieldType.Keyword,index = false,store = true)
    private String resources;// "['xxxxx','xxxxxxx']"

    @Field(type = FieldType.Float, store = true)
    private Float price;
    @Field(type = FieldType.Keyword,index = false,store = true)
    private String description;
    @Field(type = FieldType.Keyword,index = false,store = true)
    private String intro;
    @Field(type = FieldType.Keyword,index = false,store = true)
    private String qq;

    @Field(type = FieldType.Long, store = true)
    private Long startTime;

}
